import BaseModel from './baseModel'
import { get, post } from '../ajax/axios'
import { Api } from '../ajax/api'
import TimeStamp from 'time-stamp'

// 首页轮播图对象
class FeedbackModel extends BaseModel {

 
    name = ''
    phone = ''
    qq = ''
    wx = ''
    isShow = false
    date = ''
    content = ''

  get dateStr() {
    return this.date ? TimeStamp('YYYY/MM/DD', new Date(this.date)) : ''
  }

  static async getModels(data: {}, auth = false): Promise<{list: Array<FeedbackModel>, total: number}> {
    const api = auth ? Api.feedback.allAuth : Api.feedback.list
    const json = await get(api, data) as any
    return {
      list: this.modelsWithArr(json.list),
      total: json.total
    }
  }

  static add(data: {}) {
    return post(Api.feedback.add, data)
  }
}

export default FeedbackModel
